<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>学校固定资产管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <link rel="stylesheet" href="./lib/layui/css/modules/layer/default/layer.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <script src="lib/layui/lay/modules/layer.js" charset="utf-8"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
          <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
          <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
</head>

<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <blockquote class="layui-elem-quote">欢迎您：
                            <span class="x-red userName"></span>！
                            <span>
                                <script type="text/javascript">
                                    var date = new Date();
                                    document.write("今天是：" + date.getFullYear() + "年" + (date.getMonth() + 1) + "月" + date.getDate() + "日" + " 星期" + "日一二三四五六".charAt(date.getDay()));
                                </script>
                            </span>                            
                        </blockquote>                          
                    </div>
                </div>
            </div>
           
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">数据统计</div>
                    <div class="layui-card-body ">
                        <ul class="layui-row layui-col-space10 layui-this x-admin-carousel x-admin-backlog" id="allCount">
                        </ul>
                    </div>
                </div>
            </div>



            <div class="layui-fluid">
                <div class="layui-row layui-col-space15">

                    <div class="layui-col-sm12 layui-col-md6">
                        <div class="layui-card">
                            <div class="layui-card-header">资产状态</div>
                            <div class="layui-card-body" style="min-height: 280px;">
                                <div id="main1" class="layui-col-sm12" style="height: 300px;"></div>

                            </div>
                        </div>
                    </div>
                    <div class="layui-col-sm12 layui-col-md6">
                        <div class="layui-card">
                            <div class="layui-card-header">资产类型</div>
                            <div class="layui-card-body" style="min-height: 280px;">
                                <div id="main3" class="layui-col-sm12" style="height: 300px;"></div>

                            </div>
                        </div>
                    </div>
                </div>
            </div>


            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">学校固定资产管理系统信息</div>
                    <div class="layui-card-body ">
                        <table class="layui-table">
                            <tbody>
                                <tr>
                                    <th>系统版本</th>
                                    <td>0.0.100000</td>
                                </tr>

                                <tr>
                                    <th>操作系统</th>
                                    <td>Windows</td>
                                </tr>
                                <tr>
                                    <th>运行环境</th>
                                    <td>.Net FramWork 4.6.1</td>
                                </tr>
                                <tr>
                                    <th>接口地址</th>
                                    <td>http://localhost:9991</td>
                                </tr>
                                <tr>
                                    <th>接口文档</th>
                                    <td>http://localhost:9991/swagger/ui/index</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">开发团队</div>
                    <div class="layui-card-body ">
                        <table class="layui-table">
                            <tbody>
                                <tr>
                                    <th>版权所有</th>
                                    <td>张宇翔</td>
                                </tr>
                                <tr>
                                    <th>开发者</th>
                                    <td>张宇翔</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <style id="welcome_style"></style>
        </div>
    </div>
    </div>
</body>

</html>
<script src="https://cdn.bootcss.com/echarts/4.2.1-rc1/echarts.min.js"></script>
<script type="text/javascript">
    $(function () {  

        //资产统计
        $.ajax({
            type: "GET",
            headers: {
                "token": sessionStorage.getItem("token")
            },
            url: sessionStorage.getItem("api") + "assets/countinfo",
            dataType: "Json",
            success: function (res) {
                if (res.Code == 200) {
                    var countList = res.Data;
                    var html = "";
                    for (i = 0; i < countList.length; i++) {
                        var item = countList[i];
                        html += '<li class="layui-col-md2 layui-col-xs6">';
                        html += '    <a href="javascript:;" class="x-admin-backlog-body">';
                        html += '        <h3>' + item.CountName + '</h3>';
                        html += '        <p>';
                        html += '            <cite>' + item.CountNum + '</cite>' + item.Units;
                        html += '        </p>';
                        html += '    </a>';
                        html += '</li>';
                    }
                    $("#allCount").append(html);
                } else {
                    layer.msg(res.ErrorMessage);
                }
            }
        })

        //资产来源统计
        $.ajax({
            type: "GET",
            headers: {
                "token": sessionStorage.getItem("token")
            },
            url: sessionStorage.getItem("api") + "status/countinfo",
            dataType: "Json",
            success: function (res) {
                if (res.Code == 200) {
                    var countList = res.Data;

                    var name = [];
                    var count = [];
                    for (i = 0; i < countList.length; i++) {
                        name.push(countList[i].CountName);
                        count.push({ value: countList[i].CountNum, name: countList[i].CountName });
                    }
                    // 基于准备好的dom，初始化echarts实例
                    var myChart = echarts.init(document.getElementById('main1'));
                    // 指定图表的配置项和数据
                    var option = {
                        tooltip: {
                            trigger: 'item',
                            formatter: "{a} <br/>{b} : {c} ({d}%)"
                        },
                        legend: {
                            orient: 'vertical',
                            left: 'left',
                            data: name
                        },
                        series: [
                            {
                                name: '资产状态',
                                type: 'pie',
                                radius: '55%',
                                center: ['50%', '60%'],
                                data: count,
                                itemStyle: {
                                    emphasis: {
                                        shadowBlur: 10,
                                        shadowOffsetX: 0,
                                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                                    }
                                }
                            }
                        ]
                    };
                    myChart.setOption(option);


                } else {
                    layer.msg(res.ErrorMessage);
                }
            }
        })

        //资产来源统计
        $.ajax({
            type: "GET",
            headers: {
                "token": sessionStorage.getItem("token")
            },
            url: sessionStorage.getItem("api") + "types/countinfo",
            dataType: "Json",
            success: function (res) {
                if (res.Code == 200) {
                    var countList = res.Data;

                    var name = [];
                    var count = [];
                    for (i = 0; i < countList.length; i++) {
                        name.push(countList[i].CountName);
                        count.push({ value: countList[i].CountNum, name: countList[i].CountName });
                    }
                    // 基于准备好的dom，初始化echarts实例
                    var myChart = echarts.init(document.getElementById('main3'));
                    // 指定图表的配置项和数据
                    var option = {
                        tooltip: {
                            trigger: 'item',
                            formatter: "{a} <br/>{b} : {c} ({d}%)"
                        },
                        legend: {
                            orient: 'vertical',
                            left: 'left',
                            data: name
                        },
                        series: [
                            {
                                name: '资产类型',
                                type: 'pie',
                                radius: '55%',
                                center: ['50%', '60%'],
                                data: count,
                                itemStyle: {
                                    emphasis: {
                                        shadowBlur: 10,
                                        shadowOffsetX: 0,
                                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                                    }
                                }
                            }
                        ]
                    };
                    myChart.setOption(option);

                } else {
                    layer.msg(res.ErrorMessage);
                }
            }
        })
    })

</script>

<script>
    $(function () {
        $(".userName").text(sessionStorage.getItem("UserName"));
    })    
</script>